function sleep(time) {

    return new Promise((resolve, reject) => {
        setTimeout(() => {
            
            resolve();
        }, time);
    })
}



(async () => {
    for(let i = 0; i < 5 ;i++) {
    
        await sleep(1000);
        console.log(i);
    }
    
})()